<?php 
if(!isset($objectDef)) $objectDef = new objectDef($className);
$iconsSize = sfConfig::get('app_defaultViewer_iconssize', '16');
$i18N = sfContext::getInstance()->getI18N();
if(!isset($hide)) $hide = array();
if(!isset($create)) $create = true;
if(!isset($addFieldSet)) $addFieldSet = true;
?>

<script type="text/javascript">

function submitForm(idForm){
	var result = tmt.validator.validateForm(idForm);
	if(result){
		document.forms[idForm].submit();
	}
}

</script>

<?php
	$continuer = 0;

	if(count($items) > 0):

   		?><div class="showTable">
   		
   		<?php if($addFieldSet):?> 
			<fieldset><legend><?php echo $i18N->__('List of '). $i18N->__($objectDef->labelPlural,null,'forms') ?> </legend>
   		<?php endif;?>
   		<?php if($create):?>
		<a href="#">
   		<img src="/images/icons/<?php echo $iconsSize; ?>/add.png" title="'.$i18N->__('Create New').'" <?php echo $objectDef->label ?>/>
		</a>
   		<?php endif;?>
   		<div id="list_<?php echo $objectDef->className?>">
			<table class="<?php echo $tableClass?>">
			<?php echo $objectDef->renderListHeader($hide,'table',true, 0, $addOrderLink, $orderFunctionParams)?>
			<tbody class="list_elem">
			<?php 
			if(is_array($items)){
				$keys=array_keys($items);
			}
			$i=0;
			$key=0;
			foreach($items as $item):?>
				<tr>
					<?php if(isset($keys)) $key=$keys[$i];?>
					<td>
					<a class="fancy" href="<?php echo url_for('ajaxViewer/show?className=' . $className . '&id='.$item['id']);?>"><img src="/images/icons/<?php echo $iconsSize; ?>/show.png" title="<?php echo __('Show')?>"></a>
					<a class="fancy" href="<?php echo url_for('ajaxViewer/edit?className=' . $className . '&id='.$item['id']);?>"><img src="/images/icons/<?php echo $iconsSize; ?>/edit.png" title="<?php echo __('Show')?>"></a>
					<a class="fancy" href="<?php echo url_for('ajaxViewer/delete?className=' . $className . '&id='.$item['id']);?>"><img src="/images/icons/<?php echo $iconsSize; ?>/delete.png" title="<?php echo __('Show')?>"></a>
					</td>
				
				<?php echo $objectDef->renderListAttributes($item, $hide, 'table')?>
				<?php $i++; ?>
				</tr>
			<?php endforeach;?>
			<input type="hidden" id="q_list_<?php echo $objectDef->className ?>" value="<?php echo $i?>"/>
			</tbody>
			</table>
		</div>
		<?php if($addFieldSet): ?>
			</fieldset>
		<?php endif;?>
		</div>
<?php endif;?>	
